using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace LibraryAutomation.PeriodicalPublications
{
    public partial class frmPBAdd : Form
    {
        public frmPBAdd()
        {
            InitializeComponent();
        }

        private bool AddPP(string ppName, int ppIssue, string rel_date)
        {
            string stSQL = "INSERT INTO periodical_publications VALUES('" + ppName + "','" + rel_date + "','" + ppIssue + "')";
            int rowsAffected = 0;

            if (datalayer.Execute(datalayer.default_NetLibDB_Projeler_ConnectionString, stSQL, ref rowsAffected))
            {
                return true;
            }
            else
            {
                return false;
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            string name = textBox1.Text;
            int issue = Convert.ToInt16(numericUpDown1.Value);
            string rel_date = dateTimePicker1.Value.ToShortDateString();

            if (AddPP(name, issue, rel_date))
                MessageBox.Show("New periodical publication added successfully!");

        }

        private void button1_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void frmPBAdd_Load(object sender, EventArgs e)
        {

        }
    }
}